package com.lcm.weam.config;

import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/*
    springdoc的配置类，增加了代码的厚度，未使用
*/

//也可以写在启动类中
@Configuration
public class SpingDocConfiguration {
    //相当于@OpenAPIDefinition
    @Bean
    public OpenAPI springdocOpenAPI(){
        return new OpenAPI()
                .info(new Info()
                        .title("WEAM系统API文档")
                        .version("1.0")
                        .contact(new Contact().name("梁朝铭").email("805862573@qq.com").url("http://localhost:613/api-ui.html"))
                        .description("基于springdoc-openAPI-ui制作，详情请点击参考文档")
                        .license(new License().name("Apache 2.0").url("http://springdoc.org"))
                )
                .externalDocs(
                        new ExternalDocumentation().description("参考文档").url("https://springdoc.org/")
                )
                .schemaRequirement("shiro",securityScheme());
    }

    //token放在请求头中
    @Bean
    public SecurityScheme securityScheme(){
        return new SecurityScheme()
                .type(SecurityScheme.Type.HTTP)
                .name("shiro")
                .scheme("bearer")
                .in(SecurityScheme.In.HEADER);
    }

}
